package com.wx.wxsecondskill.dao;

import com.wx.wxsecondskill.po.OrderInfo;
import com.wx.wxsecondskill.po.SecondsKillOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;


/**
 * @ClassName OrderDao
 * @Author wx
 * @Description 订单dao
 * @Date 2018-11-15-22:03
 */
@Mapper
public interface OrderDao {
	
	@Select("select * from t_seconds_kill_order where user_id=#{userId} and goods_id=#{goodsId}")
	SecondsKillOrder getMiaoshaOrderByUserIdGoodsId(@Param("userId") String userId, @Param("goodsId") Integer goodsId);

	@Insert("insert into t_order_info(user_id, goods_id, goods_name, goods_count, goods_price, order_channel, status, create_date)values("
			+ "#{userId}, #{goodsId}, #{goodsName}, #{goodsCount}, #{goodsPrice}, #{orderChannel},#{status},#{createDate} )")
	@SelectKey(keyColumn="id", keyProperty="id", resultType=Integer.class, before=false, statement="select last_insert_id()")
	Integer insert(OrderInfo orderInfo);
	
	@Insert("insert into t_seconds_kill_order (user_id, goods_id, order_id)values(#{userId}, #{goodsId}, #{orderId})")
	int insertMiaoshaOrder(SecondsKillOrder miaoshaOrder);

	
}
